import 'package:flutter/material.dart';
import 'package:todos_app_core/todos_app_core.dart';

import '../models.dart';

class TodoItem extends StatelessWidget {
  final DismissDirectionCallback onDismissed;
  final GestureTapCallback onTap;
  final ValueChanged<bool?> onCheckboxChanged;
  final Todo todo;
  const TodoItem(
      {required this.todo,
      required this.onTap,
      required this.onDismissed,
      required this.onCheckboxChanged,
      Key? key})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Dismissible(
      key: ArchSampleKeys.todoItemTask(todo.id),
      onDismissed: onDismissed,
      child: ListTile(
        onTap: onTap,
        leading: Checkbox(
            key: ArchSampleKeys.todoItemCheckbox(todo.id),
            value: todo.complete,
            onChanged: onCheckboxChanged),
        title: Text(
          todo.task,
          style: Theme.of(context).textTheme.titleMedium,
        ),
      ),
    );
  }
}
